package controller;

import java.io.IOException;
import java.util.Locale;
import java.util.ResourceBundle;

import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class SearchServlet extends HttpServlet {
	public void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws IOException {
		resp.setCharacterEncoding("utf-8");
		String cx = req.getParameter("cx");
		String name = req.getParameter("name");
		
		ResourceBundle resource = ResourceBundle.getBundle("language",
				new Locale("en"));
		
		if(cx==null)
			resp.sendRedirect("/search?cx="+resource.getString("cx")+"&cof=FORID%3A10&ie=UTF-8&q="+name+"&sa=Search");
		try {
			req.getRequestDispatcher("/search.jsp").forward(req, resp);
		} catch (Exception e) {
			// TODO: handle exception
		}
	}

}
